namespace a {
  class SqList {
    public data: Array<number> = []
    public length: number
    private maxLength: number
  
    public constructor (maxLength: number = 10) {
      this.maxLength = maxLength
      this.length = 0
    }
  
    public delete(index: number): boolean {
      if (index < 0 || index > this.length - 1) {
        return false
      }
      for (let i = index; i < this.length - 1; i++) {
        this.data[i] = this.data[i+1]
      }
      this.data.splice(this.length - 1, 1)
      this.length--
      return true
    }
    
    public insert (index: number, value: number): boolean {
      if (index < 0 || this.length == this.maxLength || index > this.length) {
        return false
      }
      if (index <= this.length) {
        for (let i = this.length - 1; i >= index; i --) {
          this.data[i+1] = this.data[i]
        }
        this.data[index] = value
      }
      this.length++
      return true
    }
  
    public display (): void {
      console.log(`list length is ${this.length}\ndata is [${this.data}]`)
    }
  }
  
  function main (): void {
    let sq: SqList = new SqList(5)
    let res: boolean = sq.insert(0, 1)
    sq.insert(0, 3)
    sq.delete(0)
    sq.display()
  }
  
  main()
}
